<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" class="uname"><span class="message">请输入用户名</span>
    <script>
        //量词是设定某个模式出现的次数在[]后买跟{范围1.范围2}
        var reg = /^[a-zA-Z0-9_-]{6,16}$/; //这个模式用户输入英文字母，数字下划线 短横线但是有
        //边界符[]，这就限定了只能多选1
        //{6,16}中间不能有空格
        console.log(reg.test('a')); //true
        console.log(reg.test('8')); //true
        console.log(reg.test('aa'));//false
        console.log(reg.test('124'));//false
        console.log('-------------------');
        console.log(reg.test('zhuhaoran')); //true
        console.log(reg.test('liuxiumei')); //true
        console.log(reg.test(11111111)); //true
        console.log(reg.test(40820322040)); //true
    </script>
</body>

</html>